/*
注:以下的整型数最低位为bit0.
随机给定一个32位无符号整型数var5的值.
然后将777复制给bit7-bit17,保持其他位不变,保存到变量var6中.
取出var6的bit7-bit17的值,看是否等于777.
思路:先清空bit7-bit17的值,再写入777.之后再取出比较是否为777.
*/
#include <stdio.h>
#include "../MyFunc/MyFunc.c" //包含自定义的函数
int main(void)
{
	unsigned int var5, var6 = 0;
//	var5 = rand() * 65535;
	var5 = myFuncGenU32RandNum();
	printf("随机var5的二进制数为:\n");
	myFuncUint32ToBin(var5);
	var6 = var5 & (~(0x7FF << 7)); //清空
	var6 |= (777 << 7);            //写入
	printf("\n写入以后所得二进制数为:\n");
	myFuncUint32ToBin(var6);
	//取出var6的bit7-bit17
	unsigned int var7 = 0;
	var7 = var6 & (0x7FF << 7); //取出
	var7 = var7 >> 7;
	printf("\n\n取出的数的二进制数为:\n");
	myFuncUint32ToBin(var7);

	printf("\n");

	if (var7 == 777)
		printf("It equals to 777");
	else
		printf("It does not equal to 777");
}
